<extend name="Base:main" />
<block name="title">
<title>蔬菜外卖 - 财务管理</title>
</block>
<block name="main-content">
<div class="row">
	<div class="box col-md-6">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>图表
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round btn-default"> <i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"> <i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="alert alert-info">图片报表</div>
				<form action="__APP__/Admin/Finance/index" method="post" id="form1">
					<div class="row">
						<div class="col-xs-6 form-group">
							<label for="cdate">选择月份：</label> <input type="month"
								class="form-control" id="month" name="month"
								onchange="form1.submit();" />
						</div>
						<div class="col-xs-6 form-group">
							<label for="uid">选择用户：</label> <select data-placeholder="全部"
								id="uid" name="uid" data-rel="chosen" class="form-control"
								onchange="form1.submit();">
								<option value=""></option>
								<foreach name="users" item="user">
								<option value="{$user.id}">{$user.name}</option>
								</foreach>
							</select>
						</div>
					</div>
				</form>
				<div id="piechart" style="height: 300px"></div>
				<div id="piehover"></div>
			</div>
			<!-- end box-content -->
		</div>
		<!-- end box-inner -->
	</div>
	<div class="box col-md-6">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>菜品出售情况
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round btn-default"> <i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"> <i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="loading col-sm-12 center">
					<img src="__PUBLIC__/img/ajax-loaders/ajax-loader-5.gif">
				</div>
				<table
					class="table table-striped table-bordered bootstrap-datatable datatable responsive"
					id="orderlist" style="display: none;">
					<thead>
						<tr>
							<th>菜品</th>
							<th>数量</th>
							<th>单位</th>
							<th>成本</th>
							<th>收款</th>
							<th>利润</th>
						</tr>
					</thead>
					<tbody>
						<foreach name="food" item="v">
						<tr>
							<td>{$v.label}<small>({$v.category})</small></td>
							<td>{$v.data}</td>
							<td>{$v.unit}</td>
							<td>￥<?php echo sprintf("%.2f", $v['yprice']);?></td>
							<td>￥<?php echo sprintf("%.2f", $v['price']);?></td>
							<td>￥<?php echo sprintf("%.2f", $v['price']-$v['yprice']);?></td>
						</tr>
						</foreach>
					</tbody>
				</table>
			</div>
			<!-- end box-content -->
		</div>
		<!-- end box-inner -->
	</div>
	<!-- end box -->
	<div class="box col-md-6">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>当月每日收益统计
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round btn-default"> <i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"> <i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="loading col-sm-12 center">
					<img src="__PUBLIC__/img/ajax-loaders/ajax-loader-5.gif">
				</div>
				<table
					class="table table-striped table-bordered bootstrap-datatable datatable responsive"
					id="orderlist" style="display: none;">
					<thead>
						<tr>
							<th>日期</th>
							<th>成本</th>
							<th>收款</th>
							<th>利润</th>
						</tr>
					</thead>
					<tbody>
						<foreach name="money" item="v">
						<tr>
							<td>{$v.cdate}</td>
							<td>￥{$v.yprice}</td>
							<td>￥{$v.price}</td>
							<td>￥<?php echo $v['price']-$v['yprice'];?></td>
						</tr>
						</foreach>
						
					</tbody>
				</table>
			</div>
			<!-- end box-content -->
		</div>
		<!-- end box-inner -->
	</div>
	<!-- end box -->
	<div class="box col-md-4">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>总计
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round btn-default"> <i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"> <i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="form-group row">
					<label class="col-sm-6">总成本：</label>
					<div class="col-sm-6"><?php if($zj["yprice"])echo "￥".$zj['yprice'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">未配送款项：</label>
					<div class="col-sm-6"><?php if($zj["undist"])echo "￥".$zj['undist'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">配送中款项：</label>
					<div class="col-sm-6"><?php if($zj["disting"])echo "￥".$zj['disting'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">已收款项（含在线支付）：</label>
					<div class="col-sm-6"><?php if($zj["receipt"])echo "￥".$zj['receipt'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">未收款项：</label>
					<div class="col-sm-6"><?php if($zj["unreceipt"])echo "￥".$zj['unreceipt'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">总收款项：</label>
					<div class="col-sm-6"><?php if($zj["price"])echo "￥".$zj['price'];else echo "无";?></div>
				</div>
				<div class="form-group row">
					<label class="col-sm-6">总利润：</label>
					<div class="col-sm-6"><?php if($zj["profit"])echo "￥".$zj['profit'];else echo "无";?></div>
				</div>
			</div>
			<!-- end box-content -->
		</div>
		<!-- end box-inner -->
	</div>
</div>
</block>
<block name="js-content"> <!-- chart libraries start --> <script
	src="__PUBLIC__/bower_components/flot/excanvas.min.js"></script> <script
	src="__PUBLIC__/bower_components/flot/jquery.flot.js"></script> <script
	src="__PUBLIC__/bower_components/flot/jquery.flot.pie.js"></script> <!-- chart libraries end -->
<script type="text/javascript">
	// $('#month').change(function(e){
	// 	window.location.href= "__CONTROLLER__/index/month/"+$(this).val(); 
	// });
	var month = "<?php echo $month;?>";
	if (month == '') {
		month = "<?php echo date('Y-m'); ?>";
	}
	$('#month').val(month);
	var uid = "<?php echo $uid;?>";
	$('#uid').val(uid);
	$(function() {
		var pics = <?php echo json_encode($pics);?>;
		//pie chart
		if ($("#piechart").length) {
			$
					.plot(
							$("#piechart"),
							pics,
							{
								series : {
									pie : {
										show : true,
										radius : 1,
										label : {
											show : true,
											radius : 2 / 3,
											formatter : function(label, series) {
												return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'
														+ label
														+ '<br/>'
														+ Math
																.round(series.percent)
														+ '%</div>';
											},
											threshold : 0.1
										}
									}
								},
								grid : {
									hoverable : true,
									clickable : true
								},
								legend : {
									show : false,//是否显示右边图例
								}
							});

			function pieHover(event, pos, obj) {
				if (!obj)
					return;
				//             console.log(obj);
				percent = parseFloat(obj.series.percent).toFixed(2);
				$("#piehover").html(
						'<span style="font-weight: bold; color: ' + obj.series.color + '">'
								+ obj.series.label + obj.series.data[0][1]
								+ obj.series.unit + ' (' + percent
								+ '%)</span>');
			}

			$("#piechart").bind("plothover", pieHover);
		}
	});
</script> </block>